{title}[[Post {$listing_type_id}]]{/title}
{if $edit_user}
	{breadcrumbs}<a href="{$GLOBALS.site_url}/manage-{if $userGroupInfo.id == 'Employer' || $userGroupInfo.id == 'JobSeeker'}{$userGroupInfo.id|lower}s{else}{$userGroupInfo.id|lower}-users{/if}/">[[Manage {if $userGroupInfo.id == 'Employer' || $userGroupInfo.id == 'JobSeeker'}{$userGroupInfo.name}s{else}'{$userGroupInfo.name}' Users{/if}]]</a> &#187; <a href="{$GLOBALS.site_url}/edit-user/?user_sid={$userSID}">[[Edit User]]</a> &#187; <a href="{$GLOBALS.site_url}/add-listing/?listing_type_id={$listingTypeInfo.id}&username={$username}&edit_user=1">[[Add New {$listingTypeInfo.name}]]</a> &#187; [[Add New {$listingTypeInfo.name}]]{/breadcrumbs}
{else}
	{breadcrumbs}<a href="{$GLOBALS.site_url}/manage-listings/">[[Manage Listings]]</a> &#187; [[Add New {$listingTypeInfo.name}]]{/breadcrumbs}
{/if}
<h1><img src="{image}/icons/linedpaper32.png" border="0" alt="" class="titleicon"/> [[Add New {$listingTypeInfo.name}]] </h1>

{include file='field_errors.tpl'}

<fieldset>
	<legend>[[Add New {$listingTypeInfo.name}]]</legend>
	<form method="post" enctype="multipart/form-data" action="{$GLOBALS.site_url}/add-listing/" id="addListingForm" class="inputForm" >
		<input type="hidden" name="action" value="add" />
		<input type="hidden" name="listing_type_id" value="{$listing_type_id}" />
		<input type="hidden" id="listing_id" name="listing_id" value="{$listing_id}" />
		<input type="hidden" name="username" value="{$username}" />
		<input type="hidden" name="product_sid" value="{$product_sid}" />
		<input type="hidden" name="edit_user" value="{$edit_user}" />
		{set_token_field}
		<table>
			{foreach from=$form_fields item=form_field}
				{if $form_field.id == 'video' || $form_field.id == 'youtube'}
					{if $productInfo.video}
						<tr>
							<td valign=top>{$form_field.caption}</td>
							<td valign=top class="required">{if $form_field.is_required}*{/if}</td>
							<td>{input property=$form_field.id}</td>
						</tr>
					{/if}
				{elseif ($listing_type_id == "Job" || $listing.type.id == "Job") && $form_field.id == "anonymous"}
					{* this empty place of 'anonymous' checkbox in 'Job' listing *}
				{elseif ($listing_type_id == "Resume" || $listing.type.id == "Resume") && $form_field.id == "anonymous"}
						<tr>
							<td valign=top>{$form_field.caption}</td>
							<td valign=top class="required">{if $form_field.is_required}*{/if}</td>
							<td> {input property=$form_field.id}</td>
						</tr>
				{elseif $form_field.id == "access_type"}
					{if $listing_type_id != "Job" && $listing.type.id != "Job"}{* *}
						<tr>
							<td valign=top>{$form_field.caption}</td>
							<td valign=top class="required">{if $form_field.is_required}*{/if}</td>
							<td> {input property=$form_field.id template='resume_access.tpl'}</td>
						</tr>
					{/if}
				{elseif ($listing_type_id == "Job" || $listing.type.id == "Job") && $form_field.id == 'ApplicationSettings'}
						<tr>
							<td valign=top>{$form_field.caption}</td>
							<td valign=top class="required">{if $form_field.is_required}*{/if} </td>
							<td> {input property=$form_field.id template='applicationSettings.tpl'}</td>
						</tr>
				{elseif $form_field.type == 'location'}
						{input property=$form_field.id}
				{else}
					<tr>
						{assign var="fixInstructionsForComplexField" value=false}
						{if $form_field.type != 'complex'}
							{assign var="fixInstructionsForComplexField" value=true}
						{/if}
			            {if $form_field.id == 'ListingLogo'}
			              	<td valign=top>{$form_field.caption}</td>
							<td valign=top class="required">{if $form_field.is_required}*{/if}</td>
							<td> {input property=$form_field.id template="logo_listing.tpl"}</td>
			            {else}
							<td valign=top>{$form_field.caption}</td>
							<td valign=top class="required">{if $form_field.is_required}*{/if}</td>
							<td><div style="float: left">{input property=$form_field.id}</div>
							 {if in_array($form_field.type, array('tree', 'multilist'))}
			                    <div id="count-available-{$form_field.id}" class="mt-count-available"></div>
			               	 {/if}
                			</td>
			            {/if}
					</tr>
				{/if}
			{/foreach}
			{if $pic_limit > 0}
				<tr>
					<td valign=top> [[Add Pictures]]</td>
					<td valign=top>&nbsp;{if $form_field.is_required}*{/if}</td>
					<td>
						<div id="loading" style="display:none;">
							<img class="progBarImg" src="{$GLOBALS.user_site_url}/system/ext/jquery/progbar.gif" alt="[[Please wait ...]]" /> [[Please wait ...]]
						</div>
						<div id="UploadPics" value="{$GLOBALS.site_url}/manage-pictures/?product_sid={$product_sid}&amp;listing_sid={$listing_id}"></div>
						<br /><br />
					</td>	
				</tr>
			{/if}
			<tr>
				<td colspan="3">
                    <div class="floatRight"><input type="submit" value="[[Add]]" class="grayButton" /></div>
                </td>
			</tr>
		</table>
	</form>
</fieldset>
{literal}
<script>
	$(document).ready(function() {
		url = $("#UploadPics").attr("value");
		if (url != undefined) {
			$.ajax({
				url: url,
				beforeSend: function() {
					$("#loading").show();
					$("#UploadPics").hide();
				},
				success: function(data){
					$("#loading").hide();
					$("#UploadPics").html(data);
					$("#UploadPics").show();
				}});
		}
		$("#loading").ajaxStart(function () {
			$("#UploadPics").css({"opacity":"0.3"});
			$(this).addClass("uploadProgress");
		});
		$("#loading").ajaxComplete(function () {
			$("#UploadPics").css({"opacity":"1"});
			$(this).removeClass("uploadProgress");
		});
	});

	function deletePicture(listingId, pictureId) {
		if (confirm('Are you sure?') ) {
			var options = {
				target: "#UploadPics",
				url: '{/literal}{$GLOBALS.site_url}{literal}/manage-pictures/?listing_sid=' + listingId + '&action=delete&picture_id=' + pictureId,
				beforeSend: function(data) {
					$("#UploadPics").css({"opacity" : "0.3"});
					$("#loading").show();
				},
				success: function(data) {
					$("#UploadPics").css({"opacity" : "1"});
					$("#loading").hide();
				}
			};
			$("#messageBox").ajaxSubmit(options);
		}
	};

	function editPicture(listingId, pictureId) {
		{/literal}popUpWindow('{$GLOBALS.user_site_url}/classifieds/edit-picture/?listing_id=' + listingId + '&picture_id=' + pictureId, 560, 400, '[[Edit Picture]]');{literal}
	}
</script>
{/literal}